package hibernate;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import sunw.io.Serializable;

import bean.AmiBean;
import bean.ClasseBean;
import bean.MessageBean;


public class AmiRepository extends GenericRepositry<AmiBean, Integer> implements java.io.Serializable{

	public AmiBean GetById(Integer Id){
		Session s = HelperSessionFactory.GetSessionFactory().openSession();
		Criteria criteria = s.createCriteria(AmiBean.class).add(Restrictions.eq("id_amitie", Id));
		AmiBean cla = (AmiBean) criteria.uniqueResult();
		s.close();
		return cla;
	}

	public List<AmiBean> GetAllByIdEleveCourant(Integer Id){
		Session s = HelperSessionFactory.GetSessionFactory().openSession();
		Criteria criteria = s.createCriteria(AmiBean.class).add(Restrictions.eq("id_eleve_courant", Id));
		List<AmiBean> cla = (List<AmiBean>) criteria.list();
		s.close();
		return cla;
	}

	public List<AmiBean> GetAll(){
		Session s = HelperSessionFactory.GetSessionFactory().openSession();
		Criteria criteria = s.createCriteria(AmiBean.class);
		List<AmiBean> lst = (List<AmiBean>) criteria.list();
		s.close();
		return lst ;
	}

	//	public void SaveAmitie(AmiBean courant, AmiBean ajoute){
	//		
	//		Session s = HelperSessionFactory.GetSessionFactory().getCurrentSession();
	//		s.beginTransaction();
	//		s.save(obj);
	//		s.getTransaction().commit();
	//		s.close();
	//		
	// }

}
